#include "user_system.h"
#include "bluetooth_app.h"
#include "flash_board.h"

int main(void)
{
#if(defined(DCDC_ENABLE)) && (DCDC_ENABLE == TRUE)
    PWR_DCDCCfg(ENABLE);
#endif

    HSECFG_Capacitance(HSECap_18p);
    SetSysClock(CLK_SOURCE_HSE_PLL_62_4MHz);

#if(defined(HAL_SLEEP)) && (HAL_SLEEP == TRUE)
    GPIOA_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
    GPIOB_ModeCfg(GPIO_Pin_All, GPIO_ModeIN_PU);
#endif

#ifdef DEBUG
    GPIOA_SetBits(bTXD1);
    GPIOA_ModeCfg(bTXD1, GPIO_ModeOut_PP_5mA);
    UART1_DefInit();
#endif

  BluetoothLibraryInit();
  HardwareInit();
  GAPRole_PeripheralInit();

  // BluetoothPeripheralInit();
  PRINT("[main] : bootloaer enter \r\n");

  uint8_t OtaStatus = 0;
  if(OtaStatus){
    PRINT("[main] : stay in bootloader\r\n");
  }else{
    PRINT("[main] : jump to app\r\n");
    JUMP_FIRMWARE_APPLICATION();
  }

  while (1)
  {
    TMOS_SystemProcess();
  }

  return 0;
}
